public class Test {
    public static void main(String[] args) {
        //1. length()方法
        String s1 = "我爱你";
        System.out.println(s1.length());
        //2. charAt(index)
        System.out.println(s1.charAt(2));
        System.out.println("-----遍历字符串------");
        for (int i = 0; i < s1.length(); i++) {
            System.out.print(s1.charAt(i)+" ");
        }
        //3. toCharArray();
        char[] chars = s1.toCharArray();
        System.out.println(chars);
        //4. substring
        System.out.println(s1.substring(2));
        //5. replace
        System.out.println(s1.replace("爱","讨厌"));
        //6. contains
        System.out.println(s1.contains("爱"));
        //7. startwith
        System.out.println(s1.startsWith("我"));
        //8. split 分割 很重要，分割成字符串数组返回
        String name = "A&B&C&D";
        String[] split = name.split("&");
        System.out.println(split[0]);
    }
}
